package com.randomrpg.game.world

@serializable
class Path(val position: Tuple2[Int, Int]) {
  var up: Path = null
  var down: Path = null
  var left: Path = null
  var right: Path = null
  
  var processed = false
  
  def canGoUp = position._2 < GameMap.endPosition._2
  
  def canGoDown = position._2 > 0
  
  def canGoLeft = position._1 > 0
  
  def canGoRight = position._1 < GameMap.endPosition._1
  
  def addPath(path: Path, edge: Int) = {
    edge match {
        case 0 => up = path; path.down = this
        case 1 => down = path; path.up = this
        case 2 => left = path; path.right = this
        case 3 => right = path; path.left = this
      }
  }
  
  override def equals(obj: Any): Boolean = {
    if(obj.isInstanceOf[Path]) {
      val p = obj.asInstanceOf[Path]
      return ((position._1 == p.position._1) && (position._2 == p.position._2))
    }
    false
  }
}